package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@Getter@Setter@ToString
public class Region extends BaseDomain {
    public static  final  Integer STATE_NOT=0;
    public static  final  Integer STATE_HOT=1;


    private String name;

    private Region parent;

    private Integer state =STATE_NOT;


    public Map toMap(){
       Map<String,Object> map =new HashMap<>();
       map.put("id",id);
       map.put("text",name);
       map.put("lazyLoad",true);
        if (state==STATE_HOT) {
            map.put("tags", Arrays.asList("推荐"));
        }
       return  map;
    }

    public Object getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("parent",parent);
        if (parent != null) {
            map.put("parentId",parent.getId());
            map.put("parentName",parent.getName());
        }
        map.put("state",state);



        return JSONUtil.toJSONString(map);
    }
}